<template>
  <div
    ref="chartRef"
    style="width: 400px; height: 400px;"
  >
    我是图表
  </div>
</template>

<script>

// 引入echarts核心模块
import * as echarts from 'echarts/core'

// 引入雷达图
import {
  RadarChart
} from 'echarts/charts'
// 引入标题、提示框、图例组件
import { TitleComponent, TooltipComponent, LegendComponent } from 'echarts/components'
// 引入渲染器
import {
  CanvasRenderer
} from 'echarts/renderers'

// 集中的注册
echarts.use(
  [RadarChart, CanvasRenderer, TitleComponent, TooltipComponent, LegendComponent]
)
export default {
  name: 'RadarChart',
  //   哪个生命周期初始化
  mounted() {
    const myChart = echarts.init(this.$refs.chartRef)
    // 绘制图表
    myChart.setOption({
      title: {
        text: '基础雷达图'
      },
      tooltip: {},
      legend: {
        data: ['预算分配（Allocated Budget）', '实际开销（Actual Spending）']
      },
      radar: {
        // shape: 'circle',
        name: {
          textStyle: {
            color: '#fff',
            backgroundColor: '#999',
            borderRadius: 3,
            padding: [3, 5]
          }
        },
        // 每个区域的最高值
        indicator: [
          { name: '工作效率', max: 100 },
          { name: '考勤', max: 100 },
          { name: '积极性', max: 100 },
          { name: '帮助同事', max: 100 },
          { name: '自主学习', max: 100 },
          { name: '正确率', max: 100 }
        ]
      },
      series: [{
        name: '预算 vs 开销（Budget vs spending）',
        type: 'radar',
        // areaStyle: {normal: {}},
        data: [
          {
            value: [10, 1, 100, 5, 100, 0],
            name: '张三'
          },
          {
            value: [50, 50, 50, 50, 50, 10],
            name: '李四'
          }
        ]
      }]
    })
  }
}
</script>

<style scoped>

</style>
